<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        病人转科
    </title>
    <style>

        body {
            /*background-color: #f9f9f9;*/
            padding-botton: 50px;
        }

        .zhuyuan {
            /*border: 1px red solid;*/
            padding-left: 50px;
        }

        .topTitle {
            font-size: 20px;
            line-height: 50px;
            text-align: center;
        }

        .xiangqing span {
            margin-left: 20px;
            line-height: 30px
        }

        button {
            width: 60px;
            display: inline-block;
            height: 38px;
            line-height: 38px;
            padding: 0 18px;
            background-color: #009688;
            color: #fff;
            white-space: nowrap;
            text-align: center;
            font-size: 14px;
            border: none;
            border-radius: 2px;
            cursor: pointer;

        }
    </style>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../css/x-admin.css" media="all">
    <link rel="stylesheet" href="../css/pag.css" media="all">
    <%--<link type="text/css" rel="stylesheet" href="../js/jedate/test/jeDate-test.css">--%>
    <link type="text/css" rel="stylesheet" href="../js/jedate/skin/jedate.css">
    <script type="text/javascript" src="../js/jedate/src/jedate.js"></script>
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>住院管理</cite></a>
              <a><cite>病人查询</cite></a>
              <a><cite>病人详情</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="doRecord">
    <div class="topTitle">
        <strong>住院病人详情</strong>
    </div>
    <input type="hidden" name="userId" value="${patient.userId}">
    <div>
        <div class="x-body">
            <%--<form id="upKe">--%>
            <table class="tablelist" style="width: 500px" align="center">
                <thead>
                <tr>
                    <th>住&nbsp;&nbsp;院&nbsp;&nbsp;号：</th>
                    <th>${patient.userId}</th>
                </tr>
                <tr>
                    <th>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</th>
                    <th>${patient.userName}</th>
                </tr>
                <th>性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</th>
                <th>
                    <c:if test="${patient.sex eq 1}">男</c:if>
                    <c:if test="${patient.sex eq 2}">女</c:if>
                </th>
                </tr>
                <tr>
                    <th>年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;龄：</th>
                    <th>${patient.age}</th>
                </tr>
                <tr>
                    <th>转科科室：</th>
                    <th>
                        ${patient.zkName}&nbsp;&nbsp;转&nbsp;&nbsp;
                        <select name="kId" id="kId" style="width: 90px;">
                            <option value="0" selected="selected">---请选择---</option>
                            <c:forEach var="keshi" items="${keshiList}">
                                <option value="${keshi.kid}">${keshi.kname}</option>
                            </c:forEach>
                        </select>&nbsp;&nbsp;<font color="red">*</font></th>

                </tr>
                <tr>
                    <th>主治医师：</th>
                    <th>
                        ${patient.zdName}&nbsp;&nbsp;转&nbsp;&nbsp;
                        <select name="docId" id="docId" style="width: 90px;">
                            <option value="0" selected="selected">---请选择---</option>
                        </select>&nbsp;&nbsp;<font color="red">*</font>
                    </th>
                </tr>
                <tr>
                    <th>床&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</th>
                    <th>
                        ${patient.bNo}&nbsp;&nbsp;转&nbsp;&nbsp;
                        <select name="bNo" id="bNo">
                            <option value="0" selected="selected">---请选择---</option>
                        </select>
                        <font color="red">*</font>
                    </th>
                </tr>
                <tr>
                    <th>家庭地址：</th>
                    <th>${patient.address}</th>
                </tr>

                <tr>
                    <th>入院时间：</th>
                    <th>
                        <fmt:formatDate value="${patient.checkInTime}" pattern="YYYY-MM-dd HH:mm:ss"/>
                    </th>
                </tr>
                <tr>
                    <th>病情概要：</th>
                    <th>${patient.summary}</th>
                </tr>
                </thead>
            </table>
            <div class="providerAddBtn" align="center" style="line-height: 50px;padding-bottom: 40px">
                <div class="chuyuanfrom">
                    <button class="chuyuanbtn" lay-submit="" id="upd">确认</button>&nbsp;&nbsp;&nbsp;&nbsp;
                    <button lay-submit=""><a href="javascript:history.go(-1);" style="color: #fff">返回</a></button>
                </div>
            </div>
            <%--</form>--%>
        </div>
    </div>
</div>

<script src="../lib/layui/layui.js" charset="utf-8"></script>
<script src="../js/x-layui.js" charset="utf-8"></script>
<script src="../js/jquery2.js" charset="utf-8"></script>
<script src="../js/js.js" charset="utf-8"></script>
<script src="../js/calendar/WdatePicker.js"></script>
<script src="../js/zygl/zydj.js"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
    });

    //由科室选择框获取动态获取医生id
    $("#kId").change(function () {
        var skId = $("#kId").val();
        if (skId != '' && skId != null) {
            $.ajax({
                type: "GET",//请求类型
                url: "/doctor",//请求的url
                data: {skId: skId},//请求参数
                dataType: "json",//ajax接口（请求url）返回的数据类型
                success: function (data) {//data：返回数据（json对象）
                    $("#docId").html("");
                    var options = "<option value=\"0\" selected>---请选择---</option>";
                    for (var i = 0; i < data.length; i++) {
                        options += "<option value=\"" + data[i].docid + "\">" + data[i].docname + "</option>";
                    }
                    $("#docId").html(options);
                    var opt = "<option value=\"0\" selected>---请选择---</option>";
                    $("#bNo").html(opt);
                },
                error: function (data) {//当访问时候，404，500 等非200的错误状态码
                    layer.msg("加载床位信息失败！");
                }
            });
        } else {
            $("#docId").html("");
            var options = "<option value=\"0\" selected>---请选择---</option>";
            $("#docId").html(options);
        }
    });

    //动态获取床位
    $("#docId").change(function () {
        var skId = $("#docId").val();
        if (skId != '' && skId != null) {
            $.ajax({
                type: "GET",//请求类型
                url: "/bedList",//请求的url
                data: {kId: skId},//请求参数
                dataType: "json",//ajax接口（请求url）返回的数据类型
                success: function (data) {//data：返回数据（json对象）
                    $("#bNo").html("");
                    var options = "<option value=\"0\" selected>---请选择---</option>";
                    for (var i = 0; i < data.length; i++) {
                        options += "<option value=\"" + data[i].bNo + "\">" + data[i].bNo + "</option>";
                    }
                    $("#bNo").html(options);
                },
                error: function (data) {//当访问时候，404，500 等非200的错误状态码
                    layer.msg("加载床位信息失败！");
                }
            });
        } else {
            $("#bNo").html("");
            var options = "<option value=\"0\" selected>---请选择---</option>";
            $("#bNo").html(options);
        }
    });

    // 转科表单提交
    $("#upd").bind("click", function () {
        var uId = ${patient.userId};
        var skId = $("#kId").val();
        var sdId = $("#docId").val();
        var sbNo = $("#bNo").val();
        $.ajax({
            type: "get",
            url: "/zhuanke",
            data: {userId: uId, kId: skId, dId: sdId, bNo: sbNo},
            dataType: "json",
            success: function (data) {
                var flag = data.retMsg;
                if (flag) {
                    layer.open({
                        title: '信息',
                        content: '转科成功',
                        end: function () {
                            window.location.href = "${pageContext.request.contextPath}/brck?userId=" + uId;
                        }
                    });
                } else {
                    layer.open({
                        title: '信息',
                        content: '转科失败',
                        end: function () {
                            window.location.href = "${pageContext.request.contextPath}/brck?userId=" + uId;
                        }
                    });
                }
            },
            error:function () {
                layer.msg("转科异常");
            }
    });
    })

</script>
</body>
</html>